#include "widget.h"
#include "ui_widget.h"

#include "timethread.h"
#include <QGridLayout>
#include <QLabel>
#include <QPushButton>
#include <QSpacerItem>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    QGridLayout* layout=new QGridLayout();

    label=new QLabel(this);
    label->setFixedSize(500,300);
    label->setFrameShape(QFrame::Box);
    label->setText("SSSSSSSSSSSSSSSSSSSS");

    QPushButton* btn=new QPushButton(this);
    btn->setFixedSize(100,50);
    btn->setText("确定");

    layout->addWidget(label,0,0,1,1);
    layout->addWidget(btn,1,0,1,1);
    this->setLayout(layout);

    connect(&t,&TimeThread::sendTime,this,&Widget::showTime);
    connect(btn,&QPushButton::clicked,this,&Widget::on_btn_clicked);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_btn_clicked()
{
    t.start(); //开启线程
}

void Widget::showTime(QString Time)
{
    label->setText(Time);
}
